package com.ms.cmdlinetool;

import com.ms.service.module.account.AccountModule;
import com.ms.service.module.account.TrialAccountGroup;
import com.xpec.c4.game.system.InitData;
import com.xpec.c4.game.utility.GUIDFactory;
import com.xpec.c4.game.utility.GameUtility;

/**
 * @author TW15010
 *
 */
public class CreateTrialAccounts {
	public static void main(String[] args) {
		System.setProperty("log4j.configurationFile", "./config/log4j2.xml");
		InitData.initAll();
		GUIDFactory.setWorldId(1);
		GUIDFactory.setProcessId(1);
		
		int groupID = -1;
		try {
			groupID = Integer.valueOf(args[0]);
		} catch (Exception e) {
			printLog("can't find trial account groupID, or not an Integer value");
			return;
		}
		
		if(groupID < TrialAccountGroup.MIN_LIMIT || groupID > TrialAccountGroup.MAX_LIMIT){
			printLog("illegal trial account groupID, id must between "+TrialAccountGroup.MIN_LIMIT+" and "+TrialAccountGroup.MAX_LIMIT);
			return;
		}
		
		TrialAccountGroup group = TrialAccountGroup.lookUpByID(groupID);
		if(group == null){
			printLog("can't find groupID:"+groupID+" in TrialAccountGroup");
			return;
		}
		
		AccountModule.createAllTrialAccounts(groupID);
	}
	
	private static void printLog(String log){
		if(GameUtility.isHaveString(log)){
			String mark = "\n*********************************************\n*********************************************\n";
			System.out.println(mark+log+mark);	
		}
	}
}
